#!/bin/bash
if [ 1 -gt $# ]; then

  echo "==============================================================="
  echo "Usage: "
  echo "./init.sh config -- Configure vim runtime before first launch."
  echo "./init.sh help   -- Show help informations about this package."
  echo ""
  echo "Please run "./init.sh help" before using or launching, enpjoy!."
  echo "---------------------------------------------------------------"

elif [ "$1" == "help" ]; then

  echo "==============================================================="
  echo '-First, git clone https://gitee.com/wangweiHPC/vim-runtime.git ~/.vim'
  echo '-Second, copy ./configure_files/exuberant-ctags/winx86/ctags.exe to your system-path if windows.'
  echo '-Third, git submodule init && git submodule update --remote, clone the submodule of vim plugins.'
  echo '-Fourth, ./init.sh config'
  echo "---------------------------------------------------------------"
  echo 'Other illustrations:'
  echo '* "exuberant-ctags" is needed for this vim-runtime, for windows, a ctags.exe for x86 carried in configure_files/exuberant-ctags/winx86'
  echo '* \ntw : Create your personal code templates, execute this when first launching vim.'
  echo "---------------------------------------------------------------"

elif [ "$1" == "config" ]; then

  if [ ! -L "$HOME/.vimrc" ]; then
    echo '------------------------------------------------------------------------------------------------'
    echo "Linking vimrc file in this package to $HOME/.vimrc..."
    echo "ln -s `pwd`/configure_files/vimrc "$HOME/.vimrc""
    echo '------------------------------------------------------------------------------------------------'
    ln -s `pwd`/configure_files/vimrc "$HOME/.vimrc"
  else
    echo '------------------------------------------------------------------------------------------------'
    echo "$HOME/.vimrc file exist, remove or bake it!"
    echo '------------------------------------------------------------------------------------------------'
  fi

  if [ ! -L "$HOME/.bashrc" ]; then
    echo '------------------------------------------------------------------------------------------------'
    echo "Linking bashrc file in this package to $HOME/.bashrc..."
    echo "ln -s `pwd`/configure_files/bashrc-ubuntu20.04.4 "$HOME/.bashrc""
    echo '------------------------------------------------------------------------------------------------'
    ln -s `pwd`/configure_files/bashrc-ubuntu20.04.4 "$HOME/.bashrc"
  else
    echo '------------------------------------------------------------------------------------------------'
    echo "$HOME/.bashrc file exist, remove or bake it, if you wanna use bashrc in this package!"
    echo '------------------------------------------------------------------------------------------------'
  fi

  if [ -f "`pwd`/pack/vendor/opt/doxygen-support/doxygen-support/templates/doxygen.templates" ]; then
    echo '-------------------------------------------------------------------------------------------------'
    echo "Create a link for Doxy_LocalTemplateFile, linking to pack/vendor/opt/doxygen-support/doxygen-support, doxygen.templates, the main template file, user can modify."
    echo "ln -s `pwd`/pack/vendor/opt/doxygen-support/doxygen-support doxygen-support"
    ln -s `pwd`/pack/vendor/opt/doxygen-support/doxygen-support doxygen-support
    echo '-------------------------------------------------------------------------------------------------'
  else 
    echo '-------------------------------------------------------------------------------------------------'
    echo "Plugins not install yet, run 'git submodule update --remote', and rerun this scripte!"
    echo '-------------------------------------------------------------------------------------------------'
  fi

  echo '------------------------------------------------------------------------------------------------'
  echo "Create a link for user temp settings"
  echo "ln -s `pwd`/configure_files/extraSettings.vim ./user-tmp-settings"
  echo '------------------------------------------------------------------------------------------------'
  ln -s `pwd`/configure_files/extraSettings.vim ./user-tmp-settings

fi
